package com.hehao.java_basic.stream;


import com.hehao.common.entiy.Person;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Damon
 * @date 2022/2/23
 */
public class FilterDemo {
    public static void main(String[] args) {
        List<Person> list = Person.getList();
        list = list.stream().filter(x -> x.getSalary() > 8000).collect(Collectors.toList());
        System.out.println(list);
//        List<String> persons = list.stream().filter(x -> x.getSalary() > 8000).map(Person::getName).collect(Collectors.toList());
        List<Person> collect = list.stream().filter(x -> x.getSalary() > 8000).peek(o -> o.setName(o.getName() + "+"))
                .filter(x -> x.getSalary() < 8000).peek(o -> o.setName(o.getName() + "-"))
                .collect(Collectors.toList());
//        System.out.println(collect);

        List<Person> collect1 = list.stream().filter(x -> x.getSalary() > 8000).peek(o -> o.setName(o.getName() + "+"))
                .filter(x -> x.getSalary() < 8000).peek(o -> o.setName(o.getName() + "-"))
                .collect(Collectors.toList());
//        System.out.println(persons);

    }
}
